package com.ruoyi.reser.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.medicalPSys.domain.Xiangmuxinxi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.reser.domain.Yuyuexinxi;
import com.ruoyi.reser.service.IYuyuexinxiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-24
 */
@Api("预约信息")
@RestController
@RequestMapping("/reser/reser")
public class YuyuexinxiController extends BaseController
{
    @Autowired
    private IYuyuexinxiService yuyuexinxiService;

    /**
     * 查询预约信息列表
     */
    @ApiOperation("查询预约信息列表")
    @PreAuthorize("@ss.hasPermi('reser:reser:list')")
    @GetMapping("/list")
    public TableDataInfo list(Yuyuexinxi yuyuexinxi)
    {
        startPage();
        List<Yuyuexinxi> list = yuyuexinxiService.selectYuyuexinxiList(yuyuexinxi);
        for (int i = 0; i <list.size() ; i++) {
            Yuyuexinxi yuyuexinxi1 = list.get(i);
            System.out.print(yuyuexinxi1.getXiangmumingcheng());
        }
        return getDataTable(list);
    }

    /**
     * 导出预约信息列表
     */
    @PreAuthorize("@ss.hasPermi('reser:reser:export')")
    @Log(title = "预约信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Yuyuexinxi yuyuexinxi)
    {
        List<Yuyuexinxi> list = yuyuexinxiService.selectYuyuexinxiList(yuyuexinxi);
        ExcelUtil<Yuyuexinxi> util = new ExcelUtil<Yuyuexinxi>(Yuyuexinxi.class);
        util.exportExcel(response, list, "预约信息数据");
    }

    /**
     * 获取预约信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('reser:reser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yuyuexinxiService.selectYuyuexinxiById(id));
    }

    /**
     * 新增预约信息
     */
    @Log(title = "预约信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Yuyuexinxi yuyuexinxi)
    {
        return toAjax(yuyuexinxiService.insertYuyuexinxi(yuyuexinxi));
    }

    /**
     * 修改预约信息
     */
    @PreAuthorize("@ss.hasPermi('reser:reser:edit')")
    @Log(title = "预约信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Yuyuexinxi yuyuexinxi)
    {
        return toAjax(yuyuexinxiService.updateYuyuexinxi(yuyuexinxi));
    }

    /**
     * 删除预约信息
     */
    @PreAuthorize("@ss.hasPermi('reser:reser:remove')")
    @Log(title = "预约信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yuyuexinxiService.deleteYuyuexinxiByIds(ids));
    }
}
